#include<iostream>

int cmmdc(int, int);
int cmmdc(int*);

const int max_index = 5;

int cmmdc(int a, int b)
  {
    if(a == 0) return b;
    while(b != 0)
    {
      if(a > b) a -= b;
        else b -= a; 
    }    
    return a;
  }

int cmmdc(int* v)
  {
    int gcd;
    gcd = cmmdc(v[0], v[1]);
    std::cout<<gcd<<" ";
    for(int i = 2; i < max_index - 1; i++)
      gcd = cmmdc(v[i], gcd);
    return gcd;
  }

int main()
  {
    int x[max_index];
    for(int i = 0;i < max_index; i++)
      {
        std::cout<<"\nx["<<i<<"]=";
	std::cin>>x[i];
      }
    std::cout<<"cmmdc(x)="<<cmmdc(x)<<"\n";
    return 0;
  }